package com.orange.cloud.domain;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult<T> {

    private T data;
    private String message;
    private Integer code;

    public static CommonResult build(Integer code, String message){
        CommonResult result = new CommonResult();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }

    public CommonResult(T data) {
        this(data, "操作成功", 200);
    }

    public static CommonResult ok(String message){
        return build(200, message);
    }

    public static CommonResult error(String message){
        return build(500, message);
    }
}
